package com.mop.service;

import com.mop.mapper.UserMapper;
import com.mop.pojo.Item;
import com.mop.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import java.util.List;
import java.util.UUID;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
       List<User> userList= userMapper.findAll();
        return userList;
    }

    @Override
    public String login(User user) {
        String password = user.getPassword();
        String md5Pass=DigestUtils.md5DigestAsHex(password.getBytes());
        user.setPassword(md5Pass);
        User userDB=userMapper.findUserByUP(user);
        if(userDB==null){
            return null;
        }
        String token = UUID.randomUUID().toString().replace("_", "");

        return token;
    }




}
